if (typeof jQuery == "undefined") {
    var scriptObj = document.createElement("script");
    scriptObj.src = "/script/jquery.min.js";
    scriptObj.type = "text/javascript";
    var head=document.getElementsByTagName("head")[0];
    head.insertBefore(scriptObj,head.firstChild);
}

jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

$(document).ready(function(){
//	ZFDebugLoad();
//	jQuery.noConflict();
    ZFDebugCollapsed();
});

function ZFDebugCollapsed() {
    if (jQuery.cookie('ZFDebugCollapsed') == 1) {
        ZFDebugPanel();
        jQuery("#ZFDebug_toggler").html("&#187;");
        return jQuery("#ZFDebug_debug").css("left", "-"+parseInt(jQuery("#ZFDebug_debug").outerWidth()-jQuery("#ZFDebug_toggler").outerWidth()+1)+"px");
    }
}

function ZFDebugPanel(name) {
    jQuery(".ZFDebug_panel").each(function(i){
        if(jQuery(this).css("display") == "block") {
            jQuery(this).slideUp();
        } else {
            if (jQuery(this).attr("id") == name)
            	jQuery(this).slideDown();
            else
            	jQuery(this).slideUp();
        }
    });
}
 
function ZFDebugSlideBar() {
    if (jQuery("#ZFDebug_debug").position().left > 0) {
    	jQuery.cookie('ZFDebugCollapsed', 1, "expires=;path=/");
        ZFDebugPanel();
        jQuery("#ZFDebug_toggler").html("&#187;");
        return jQuery("#ZFDebug_debug").animate({left:"-"+parseInt(jQuery("#ZFDebug_debug").outerWidth()-jQuery("#ZFDebug_toggler").outerWidth()+1)+"px"}, "normal", "swing");
    } else {
    	jQuery.cookie('ZFDebugCollapsed', 0, "expires=;path=/");
        jQuery("#ZFDebug_toggler").html("&#171;");
        return jQuery("#ZFDebug_debug").animate({left:"5px"}, "normal", "swing");
    }
}
 
function ZFDebugToggleElement(name, whenHidden, whenVisible){
    if(jQuery(name).css("display")=="none"){
        jQuery(whenVisible).show();
        jQuery(whenHidden).hide();
    } else {
        jQuery(whenVisible).hide();
        jQuery(whenHidden).show();
    }
    jQuery(name).slideToggle();
}